<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link type="text/css" rel="stylesheet" href="<?php echo $this->basePath('public/css/dbblack/css/product.css'); ?>" />
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/jquery.enlarge.js'); ?>"></script>

<div class="container">
	<div class="goods-detail mt10 clearfix" style="position: relative;">
		<table>
			<tr>
				<td width="10%">
					<img style="border:1px solid #e4e4e4;" src="<?php echo ($this->brand_info->brand_logo != '' ? $this->basePath($this->brand_info->brand_logo) : $this->basePath($this->frontwebsite()->getGoodsUploadIni('brand', 'brand_image_default'))); ?>">
				</td>
				<td style="padding-left: 10px;"><?php echo $this->brand_info->brand_info; ?></td>
			</tr>
		</table>
		<div class="content">
			<div class="mt10 product_show  product-list  clearfix">
				<div class="clearfix" >
					<div class="sort-bar">
						<span><?php echo $this->translate('排序'); ?>：</span>
						<?php
						$sort_c_str   = $this->sort_c != '' ? '&sort_c=' . $this->sort_c : '';

						$price_sort = 'ASC';
						$price_sort_class = '';
						if (isset($this->sort_selected) and ($this->sort_selected == 'goods_shop_priceASC' or $this->sort_selected == 'goods_shop_priceDESC')) {
							if($this->sort_selected == 'goods_shop_priceASC') {
								$price_sort = 'DESC';
								$price_sort_class = 'class="current-2"';
							}
							if($this->sort_selected == 'goods_shop_priceDESC') {
								$price_sort = 'ASC';
								$price_sort_class = 'class="current"';
							}
						}
						$time_sort = 'ASC';
						$time_sort_class = '';
						if(!isset($this->sort_selected)) $time_sort_class = 'class="current"';
						if (isset($this->sort_selected) and ($this->sort_selected == 'goods_add_timeASC' or $this->sort_selected == 'goods_add_timeDESC')) {
							if($this->sort_selected == 'goods_add_timeASC') {
								$time_sort = 'DESC';
								$time_sort_class = 'class="current-2"';
							}
							if($this->sort_selected == 'goods_add_timeDESC') {
								$time_sort = 'ASC';
								$time_sort_class = 'class="current"';
							}
						}
						$click_sort = 'ASC';
						$click_sort_class = '';
						if (isset($this->sort_selected) and ($this->sort_selected == 'goods_clickASC' or $this->sort_selected == 'goods_clickDESC')) {
							if($this->sort_selected == 'goods_clickASC') {
								$click_sort = 'DESC';
								$click_sort_class = 'class="current-2"';
							}
							if($this->sort_selected == 'goods_clickDESC') {
								$click_sort = 'ASC';
								$click_sort_class = 'class="current"';
							}
						}
						?>
						<a href="?time_sort=<?php echo $time_sort.$sort_c_str; ?>" <?php echo $time_sort_class; ?> ><?php echo $this->translate('默认'); ?><i class="ie6png"></i></a>
						<a href="?price_sort=<?php echo $price_sort.$sort_c_str; ?>" <?php echo $price_sort_class ?> ><?php echo $this->translate('价格'); ?><i class="ie6png"></i></a>
						<a href="?click_sort=<?php echo $click_sort.$sort_c_str; ?>" <?php echo $click_sort_class; ?> ><?php echo $this->translate('人气'); ?><i class="ie6png"></i></a>
					</div>
				</div>
				<dl>
					<dd>
						<ul class="clearfix">
							<?php
                            $goodsIdStr = '';
                            if ($this->goods_list->getTotalItemCount() > 0) { foreach ($this->goods_list as $goods_value) {
                                $goodsIdStr .= $goods_value['goods_id'] . ',';
                                ?>
							<li>
								<dl class="product">
					<dt class="img">
						<a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['one_class_id'])); ?>" title="<?php echo $this->escapeHtml($goods_value['goods_name']); ?>">
							<img alt="<?php echo $this->escapeHtml($goods_value['goods_name']); ?>" src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($goods_value['goods_thumbnail_image'])); ?>" width="220">
						</a>
					</dt>
					<dd class="title list_title"><a title="<?php echo $this->escapeHtml($goods_value['goods_name']); ?>" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['one_class_id'])); ?>"><?php echo $this->escapeHtml($goods_value['goods_name']); ?></a></dd>
					<dd><span class="price"><?php
							$goodsPrice = (isset($goods_value['group_price']) and $goods_value['group_price'] > 0) ? $goods_value['group_price'] : $goods_value['goods_shop_price'];
							echo $this->frontwebsite()->shopPriceExtend($goodsPrice);
							?></span></dd>
					<dd class="product-ext">
						<a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['one_class_id'])); ?>" id="add-cart" class="btn btn-main" style="padding:6px 20px;"><?php echo $this->translate('商品详情'); ?></a>&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:;" class="attention btn btn-info fr" data-class-id="<?php echo $goods_value['one_class_id']; ?>" val="<?php echo $goods_value['goods_id']; ?>"><i class="icon-hart-16 ie6png"></i><span><?php echo $this->translate('收藏'); ?></span></a>
					</dd>
				</dl>
				</li>
				<?php } } ?>

				</ul>
				</dd>
				</dl>
			</div>
			<div class="page-nav">
                <?php echo ( count($this->goods_list) > 0 ) ? $this->paginationControl($this->goods_list, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontbrand/default/front-brand-id',array('action'=>'brandGoods', 'brand_id'=>$this->brand_info->brand_id)))) : ""; ?>
			</div>
		</div>
	</div>
</div>

<script>

	$(".attention").on("click",function(){
		var id = $(this).attr("val");
		var class_id = $(this).attr("data-class-id");
		$.post("<?php echo $this->url('frontuser/default',array('action'=>'addFavorites')); ?>",{goods_id:id,class_id:class_id},function(data){
			if(data=='true') {
				art.dialog.tips("<p class='success'><?php echo $this->translate('该商品成功加入收藏！'); ?></p>");
			} else {
				if(data == 'login_false') {
					art.dialog.tips("<p class='warning'><?php echo $this->translate('您还没有登录，无法收藏商品！'); ?></p>");
				} else if (data == 'goods_exists') {
					art.dialog.tips("<p class='success'><?php echo $this->translate('您已经收藏过该商品！'); ?></p>");
				} else {
					art.dialog.tips("<p class='warning'><?php echo $this->translate('商品收藏不成功！'); ?></p>");
				}
			}
		})
	})
</script>
<?php if(defined('FRONT_CACHE_STATE') and FRONT_CACHE_STATE == 'true') { ?>
    <script>
        $.post('<?php echo $this->url('frontgoodslist/default',array('action'=>'ajaxGoodsGroupPrice')); ?>',{goodsIdStr:'<?=$goodsIdStr?>'}, function(data){
            if(data.state == 'true') {
                for (var i = 0; i < data.list.length; i++) {
                    $('#goods_price_'+data.list[i].id).html(data.list[i].price);
                }
            }
        },'json');
    </script>
<?php } ?>
